package com.biz.primus.ms.promotion.api;

import com.biz.primus.base.vo.PageVo;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.promotion.vo.*;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.promotion.service.promotion.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author david-liu
 */
@RestController
@RequestMapping(value = "soa/promotion/management")
public class PromotionManagementApiController extends BaseApiController {

    @Autowired
    private SpecialOfferPromotionManagementService specialOfferPromotionManagementService;

    @Autowired
    private UserFirstOrderCutPromotionManagementService userFirstOrderCutPromotionManagementService;

    @Autowired
    private PurchaseGiftPromotionManagementService purchaseGiftPromotionManagementService;

    @Autowired
    private DiscountPromotionManagementService discountPromotionManagementService;

    @Autowired
    private CutPriceSalePromotionManagementService cutPriceSalePromotionManagementService;

    @Autowired
    private LuckyOrderPromotionManagementService luckyOrderPromotionManagementService;

    @PostMapping(value = "/updateSpecialOfferPromotion")
    public Boolean updateSpecialOfferPromotion(@RequestBody SpecialOfferPromotionVo vo) {
        return specialOfferPromotionManagementService.createSpecialOfferPromotion(vo);
    }

    @PostMapping(value = "/getSpecialOfferPromotions")
    public SpringPageVO<SpecialOfferPromotionVo> getSpecialOfferPromotions(@RequestBody PageVo pageVo) {
        return specialOfferPromotionManagementService.getSpecialOfferPromotions(pageVo);
    }

    @GetMapping(value = "/getSpecialOfferPromotion")
    public SpecialOfferPromotionVo getSpecialOfferPromotion(@RequestParam("promotionId") Long promotionId) {
        return specialOfferPromotionManagementService.getSpecialOfferPromotion(promotionId);
    }

    @GetMapping(value = "/toggleSpecialOfferPromotionStatus")
    public Boolean toggleSpecialOfferPromotionStatus(@RequestParam("promotionId") Long promotionId) {
        return specialOfferPromotionManagementService.toggleSpecialOfferPromotionStatus(promotionId);
    }

    @PostMapping(value = "/updateUserFirstOrderPromotion")
    public Boolean updateUserFirstOrderPromotion(@RequestBody UserFirstOrderCutPromotionVo vo) {
        return userFirstOrderCutPromotionManagementService.updateUserFirstOrderCutPromotion(vo);
    }

    @PostMapping(value = "/getUserFirstOrderPromotions")
    public SpringPageVO<UserFirstOrderCutPromotionVo> getUserFirstOrderPromotions(@RequestBody PageVo pageVo) {
        return userFirstOrderCutPromotionManagementService.getUserFirstOrderCutPromotions(pageVo);
    }

    @GetMapping(value = "/getUserFirstOrderPromotion")
    public UserFirstOrderCutPromotionVo getUserFirstOrderPromotion(@RequestParam("promotionId") Long promotionId) {
        return userFirstOrderCutPromotionManagementService.getUserFirstOrderCutPromotion(promotionId);
    }

    @GetMapping(value = "/toggleUserFirstOrderStatus")
    public Boolean toggleUserFirstOrderStatus(@RequestParam("promotionId") Long promotionId) {
        return userFirstOrderCutPromotionManagementService.toggleUserFirstOrderCutPromotionStatus(promotionId);
    }

    @PostMapping(value = "/updatePurchaseGiftPromotion")
    public Boolean updatePurchaseGiftPromotion(@RequestBody PurchaseGiftPromotionVo vo) {
        return purchaseGiftPromotionManagementService.updatePurchaseGiftPromotion(vo);
    }

    @PostMapping(value = "/getPurchaseGiftPromotions")
    public SpringPageVO<PurchaseGiftPromotionVo> getPurchaseGiftPromotions(@RequestBody PageVo pageVo) {
        return purchaseGiftPromotionManagementService.getPurchaseGiftPromotions(pageVo);
    }

    @GetMapping(value = "/getPurchaseGiftPromotion")
    public PurchaseGiftPromotionVo getPurchaseGiftPromotion(@RequestParam("promotionId") Long promotionId) {
        return purchaseGiftPromotionManagementService.getPurchaseGiftPromotion(promotionId);
    }

    @GetMapping(value = "/togglePurchaseGiftPromotionStatus")
    public Boolean togglePurchaseGiftPromotionStatus(@RequestParam("promotionId") Long promotionId) {
        return purchaseGiftPromotionManagementService.togglePurchaseGiftPromotionStatus(promotionId);
    }

    @PostMapping(value = "/updateDiscountPromotion")
    public Boolean updateDiscountPromotion(@RequestBody DiscountPromotionVo vo) {
        return discountPromotionManagementService.updateDiscountPromotion(vo);
    }

    @PostMapping(value = "/getDiscountPromotions")
    public SpringPageVO<DiscountPromotionVo> getDiscountPromotions(@RequestBody PageVo pageVo) {
        return discountPromotionManagementService.getDiscountPromotions(pageVo);
    }

    @GetMapping(value = "/getDiscountPromotion")
    public DiscountPromotionVo getDiscountPromotion(@RequestParam("promotionId") Long promotionId) {
        return discountPromotionManagementService.getDiscountPromotion(promotionId);
    }

    @GetMapping(value = "/toggleDiscountPromotionStatus")
    public Boolean toggleDiscountPromotionStatus(@RequestParam("promotionId") Long promotionId) {
        return discountPromotionManagementService.toggleDiscountPromotionStatus(promotionId);
    }

    @PostMapping(value = "/updateCutPriceSalePromotion")
    public Boolean updateCutPriceSalePromotion(@RequestBody CutPriceSalePromotionVo vo) {
        return cutPriceSalePromotionManagementService.updateCutPriceSalePromotion(vo);
    }

    @PostMapping(value = "/getCutPriceSalePromotions")
    public SpringPageVO<CutPriceSalePromotionVo> getCutPriceSalePromotions(@RequestBody PageVo pageVo) {
        return cutPriceSalePromotionManagementService.getCutPriceSalePromotions(pageVo);
    }

    @GetMapping(value = "/getCutPriceSalePromotion")
    public CutPriceSalePromotionVo getCutPriceSalePromotion(@RequestParam("promotionId") Long promotionId) {
        return cutPriceSalePromotionManagementService.getCutPriceSalePromotion(promotionId);
    }

    @GetMapping(value = "/toggleCutPriceSalePromotionStatus")
    public Boolean toggleCutPriceSalePromotionStatus(@RequestParam("promotionId") Long promotionId) {
        return cutPriceSalePromotionManagementService.toggleCutPriceSalePromotionStatus(promotionId);
    }

    @PostMapping(value = "/updateLuckyOrderPromotion")
    public Boolean updateLuckyOrderPromotion(@RequestBody LuckyOrderPromotionVo vo) {
        return luckyOrderPromotionManagementService.updateLuckyOrderPromotion(vo);
    }

    @PostMapping(value = "/getLuckyOrderPromotions")
    public SpringPageVO<LuckyOrderPromotionVo> getLuckyOrderPromotions(@RequestBody PageVo pageVo) {
        return luckyOrderPromotionManagementService.getLuckyOrderPromotions(pageVo);
    }

    @GetMapping(value = "/getCutPriceSalePromotion")
    public LuckyOrderPromotionVo getLuckyOrderPromotion(@RequestParam("promotionId") Long promotionId) {
        return luckyOrderPromotionManagementService.getLuckyOrderPromotion(promotionId);
    }

    @GetMapping(value = "/toggleLuckyOrderPromotionStatus")
    public Boolean toggleLuckyOrderPromotionStatus(@RequestParam("promotionId") Long promotionId) {
        return luckyOrderPromotionManagementService.toggleLuckyOrderPromotionStatus(promotionId);
    }
}
